using System;
using log4net;
using System.Linq;
using log4net.Config;
using log4net.Appender;
using System.Windows.Forms;

namespace SysSUFront
{
    public class Logger
    {
        private static Logger instance;
        private ILog log;
        private TextBoxBase textBox;

        public static Logger Default
        {
            get
            {
                if (instance == null)
                    instance = new Logger();

                return instance;
            }
        }

        private Logger()
        {
            XmlConfigurator.Configure();
            log = LogManager.GetLogger("DebugLogger");
        }

        public TextBoxBase Out { set { TextBoxAppender.SetTextBox(value); } }

        public void Debug(string message)
        {
            if (!string.IsNullOrEmpty(message))
                log.Debug(message + "\n");
        }

        public void Info(string message)
        {
            if (!string.IsNullOrEmpty(message))
                log.Info(message + "\n");
        }

        public void Warn(string message)
        {
            if (!string.IsNullOrEmpty(message))
                log.Warn(message + "\n");
        }

        public void Error(string message)
        {
            if (!string.IsNullOrEmpty(message))
                log.Error(message + "\n");
        }
    }
}